import io

from fontTools.ttLib import TTFont
from utils.font import get_font_maps

# from PIL import Image , ImageFont,ImageDraw
#
# from  ddddocr import DdddOcr
#
# #指定解析字体文件
# font = TTFont("./static/font/file")
#
# #指定绘制的字体文件
# img_font = ImageFont.truetype("./static/font/file",10)
#
# font_map = {}
#
# for code , name in font.getBestCmap().items():
#     if code == 120:
#         continue
#
#     #创建图片
#     img = Image.new("RGB",(32,32),(255,255,255))
#     # print(chr(code))
#
#
#     #绘制图片
#     draw = ImageDraw.Draw(img)
#     draw.text((0,0),chr(code),font=img_font,fill=(0,0,0))
#
#     # 保存 图片
#     # img.save(f"./static/font/img/{code}.png")
#     img_bytes = io.BytesIO()
#     img.save(img_bytes,"JPEG")
#     # print(img_bytes.getvalue())
#
#     ocr = DdddOcr(show_ad= False)
#
#     r = ocr.classification(img_bytes.getvalue())
#
#     font_map[hex(code)] = r
#
s = "&#xf05f&#xf7f8&#xeb8a"
#
#     font_maps = get_font_maps("./static/font/file")
font_maps = get_font_maps("./static/font/file")
result = ""
for items in s.split("&")[1:]:

    print(items.replace("#", "0"))

    result += font_maps[items.replace("#", "0")]

    print(result)



# print(font_map)











